/*
Created		10/9/2011
Modified		10/27/2011
Project		
Model			
Company		
Author		
Version		
Database		MS SQL 2005 
*/







Drop table [EStoreUser] 
go
Drop table [GeneralCategory] 
go
Drop table [LuckCyclePoint] 
go
Drop table [LuckCycleSetting] 
go
Drop table [UsePointBackage] 
go
Drop table [SupportLink] 
go
Drop table [PayOnline] 
go
Drop table [PointBackage] 
go
Drop table [EStorePoint] 
go
Drop table [EStore] 
go
Drop table [PermissionForm] 
go
Drop table [FormGroup] 
go
Drop table [PermissionGroup] 
go
Drop table [FormEvents] 
go
Drop table [Forms] 
go
Drop table [Users] 
go




















Create table [Users]
(
	[Users_Id] Bigint NOT NULL,
	[UserName] Nvarchar(40) NULL,
	[BirdthDay] Datetime NULL,
	[Avatar] Nvarchar(50) NULL,
	[Sex] Smallint NULL,
	[Identity] Nvarchar(50) NULL,
	[References] Nvarchar(50) NULL,
	[Address] Nvarchar(50) NULL,
	[HomePhone] Nvarchar(50) NULL,
	[MobilePhone] Nvarchar(50) NULL,
	[SkypeNick] Nvarchar(50) NULL,
	[YahooNick] Nvarchar(1) NULL,
	[FullName] Nvarchar(50) NULL,
	[Password] Nvarchar(1) NULL,
	[Email] Nvarchar(50) NULL,
	[Users_Type] Smallint NULL,
	[Users_IsEnable] Char(1) NULL,
Primary Key ([Users_Id])
) 
go

Create table [Forms]
(
	[Form_Id] Bigint NOT NULL,
	[FormGroup_Id] Bigint NOT NULL,
	[Form_Name] Nvarchar(50) NULL,
	[Form_ClassName] Varchar(50) NULL,
	[Form_Image] Nvarchar(50) NULL,
Primary Key ([Form_Id])
) 
go

Create table [FormEvents]
(
	[Event_Id] Bigint NOT NULL,
	[Event_DisplayName] Varchar(50) NULL,
	[FormEvent_Name] Nvarchar(50) NULL,
	[FormEvents_ControlType] Nvarchar(50) NULL,
	[Form_Id] Bigint NOT NULL,
Primary Key ([Event_Id])
) 
go

Create table [PermissionGroup]
(
	[PermissionGroup_Id] Bigint NOT NULL,
	[PermissionGroup_Name] Bigint NULL,
Primary Key ([PermissionGroup_Id])
) 
go

Create table [FormGroup]
(
	[FormGroup_Id] Bigint NOT NULL,
	[FormGroup_Name] Nvarchar(50) NULL,
Primary Key ([FormGroup_Id])
) 
go

Create table [PermissionForm]
(
	[PermissionForm_Id] Bigint NOT NULL,
	[PermissionForm_IsPermission] Bit NULL,
	[Form_Id] Bigint NOT NULL,
	[Event_Id] Bigint NOT NULL,
	[PermissionGroup_Id] Bigint NOT NULL,
Primary Key ([PermissionForm_Id])
) 
go

Create table [EStore]
(
	[EStore_Id] Bigint NOT NULL,
	[Users_Id] Bigint NOT NULL,
	[EStore_Name] Nvarchar(500) NULL,
	[EStore_Address] Nvarchar(500) NULL,
	[Estore_HomePhone] Varchar(20) NULL,
	[EStore_MobilePhone] Nvarchar(20) NULL,
	[EStore_Fax] Varchar(20) NULL,
	[EStore_CodeTax] Nvarchar(20) NULL,
	[EStore_Website] Nvarchar(300) NULL,
	[EStore_Logo] Nvarchar(300) NULL,
	[EStore_BriefIntroduction] Text NULL,
	[EStore_NickYahoo] Nvarchar(100) NULL,
	[EStore_NickSkype] Nvarchar(100) NULL,
	[EStore_View] Integer NULL,
	[EStore_LuckCyclePoint] Integer NULL,
	[EStore_TotalPoint] Integer NULL,
	[EStore_FeedbackNo] Integer NULL,
	[EStore_CommentNo] Integer NULL,
	[EStore_Vote] Integer NULL,
	[EStoreCategory_Id] Bigint NULL,
	[Province_Id] Bigint NULL,
	[EStoreKind_Id] Bigint NULL,
	[EStoreStatus_Id] Bigint NULL,
	[EStoreStatus_FromDate] Datetime NULL,
	[EStoreStatus_ToDate] Datetime NULL,
	[EStore_ParentId] Bigint NULL,
	[EStore_Representative] Nvarchar(200) NULL,
Primary Key ([EStore_Id])
) 
go

Create table [EStorePoint]
(
	[EStorePoint_Id] Bigint NOT NULL,
	[EStore_Id] Bigint NOT NULL,
	[EStorePoint_Point] Integer NULL,
	[EStorePoint_Date] Datetime NULL,
	[EStorePoint_Note] Nvarchar(50) NULL,
	[EStorePoint_Type] Smallint NULL,
Primary Key ([EStorePoint_Id])
) 
go

Create table [PointBackage]
(
	[PointBackage_Id] Bigint NOT NULL,
	[PointBackage_Name] Nvarchar(50) NULL,
	[PointBackage_Point] Integer NULL,
	[PointBackage_Money] Float NULL,
	[PointBackage_Type] Smallint NULL,
Primary Key ([PointBackage_Id])
) 
go

Create table [PayOnline]
(
	[PayOnline_Id] Bigint NOT NULL,
	[PayOnline_Name] Nvarchar(400) NULL,
	[PayOnline_Email] Nvarchar(50) NULL,
	[PayOnline_MerchantId] Nvarchar(100) NULL,
	[PayOnline_SecurePass] Nvarchar(100) NULL,
Primary Key ([PayOnline_Id])
) 
go

Create table [SupportLink]
(
	[SupportLink_Id] Bigint NOT NULL,
	[SupportLink_Name] Nvarchar(200) NULL,
	[SupportLink_Link] Nvarchar(400) NULL,
	[SupportLink_Type] Smallint NULL,
Primary Key ([SupportLink_Id])
) 
go

Create table [UsePointBackage]
(
	[UsePointBackage_Id] Bigint NOT NULL,
	[UsePointBackage_Name] Nvarchar(50) NULL,
	[UsePointBackage_Point] Integer NULL,
	[UsePointBackage_FromDate] Datetime NULL,
	[UsePointBackage_ToDate] Datetime NULL,
	[UsePointBackage_Type] Smallint NULL,
	[UsePointBackage_DateAmount] Smallint NULL,
Primary Key ([UsePointBackage_Id])
) 
go

Create table [LuckCycleSetting]
(
	[LuckCycleSetting_Id] Bigint NOT NULL,
	[LuckCycleSetting_Point] Integer NULL,
	[LuckCycleSetting_Time] Float NULL,
	[LuckCycleSetting_Type] Smallint NULL,
Primary Key ([LuckCycleSetting_Id])
) 
go

Create table [LuckCyclePoint]
(
	[LuckCyclePoint_Id] Bigint NOT NULL,
	[EStore_Id] Bigint NOT NULL,
	[LuckCyclePoint_Point] Integer NULL,
	[LuckCyclePoint_Date] Datetime NULL,
	[LuckCyclePoint_Type] Smallint NULL,
	[LuckCyclePoint_UseKind] Smallint NULL,
Primary Key ([LuckCyclePoint_Id])
) 
go

Create table [GeneralCategory]
(
	[GeneralCategory_Id] Bigint NOT NULL,
	[GeneralCategory_Code] Nvarchar(200) NULL,
	[GeneralCategory_Name] Nvarchar(1000) NULL,
	[GeneralCategory_Type] Smallint NULL,
Primary Key ([GeneralCategory_Id])
) 
go

Create table [EStoreUser]
(
	[EStoreUser_Id] Bigint NOT NULL,
	[EStore_Id] Bigint NOT NULL,
	[Users_Id] Bigint NOT NULL,
Primary Key ([EStoreUser_Id])
) 
go































Alter table [EStore] add  foreign key([Users_Id]) references [Users] ([Users_Id])  on update no action on delete no action 
go
Alter table [EStoreUser] add  foreign key([Users_Id]) references [Users] ([Users_Id])  on update no action on delete no action 
go
Alter table [FormEvents] add  foreign key([Form_Id]) references [Forms] ([Form_Id])  on update no action on delete no action 
go
Alter table [PermissionForm] add  foreign key([Form_Id]) references [Forms] ([Form_Id])  on update no action on delete no action 
go
Alter table [PermissionForm] add  foreign key([Event_Id]) references [FormEvents] ([Event_Id])  on update no action on delete no action 
go
Alter table [PermissionForm] add  foreign key([PermissionGroup_Id]) references [PermissionGroup] ([PermissionGroup_Id])  on update no action on delete no action 
go
Alter table [Forms] add  foreign key([FormGroup_Id]) references [FormGroup] ([FormGroup_Id])  on update no action on delete no action 
go
Alter table [EStorePoint] add  foreign key([EStore_Id]) references [EStore] ([EStore_Id])  on update no action on delete no action 
go
Alter table [LuckCyclePoint] add  foreign key([EStore_Id]) references [EStore] ([EStore_Id])  on update no action on delete no action 
go
Alter table [EStoreUser] add  foreign key([EStore_Id]) references [EStore] ([EStore_Id])  on update no action on delete no action 
go


Set quoted_identifier on
go









Set quoted_identifier off
go





